package com.mall4jcola.cloud.tunnel.database.dataobj;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.mall4jcola.cloud.core.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * 用户账号信息表
 * TODO
 * 用于记录第三方登录账号信息以及站内账号信息
 *
 * @author hmxchen
 */
@Data
@Entity
@Table(name = "user_auths")
@JsonIgnoreProperties(value = { "hibernateLazyInitializer"})
@EqualsAndHashCode(callSuper = true)
public class UserAuthsDO extends BaseEntity {
    /**
     * 授权ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ua_id")
    private Long uaId;
    /**
     * 用户ID
     */
    @Column(name = "user_id", nullable = false, length = 20)
    private Long userId;
    /**
     * 身份类型 站内：SYS_PWD 手机号 PHONE_NO
     */
    @Column(name = "identity_type", nullable = false, length = 32)
    private String identityType;
    /**
     * 身份唯一标识
     */
    @Column(name = "identifier", nullable = false, length = 64)
    private String identifier;
    /**
     * 授权凭证
     */
    @Column(name = "credential")
    private String credential;
    /**
     * 最近一次登录时间
     */
    @Column(name = "last_time", nullable = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastTime;
    /**
     * 最近一次登录IP
     */
    @Column(name = "last_ip", nullable = false, length = 32)
    private String lastIp;
}
